package com.pig4cloud.pig.djjk.controller;


import com.alibaba.fastjson.JSONObject;
import com.pig4cloud.pig.common.security.annotation.Inner;
import com.pig4cloud.pig.djjk.service.DispatchService;
import com.pig4cloud.pig.djjk.service.wd.WdTrackService;
import com.pig4cloud.pig.djjk.service.wd.WdboxService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @className: DeviceController
 * @description: TODO 类描述
 * @author: liumingkun
 * @date: 2023/6/3
 **/
@RestController
@Inner(value = false)
@RequestMapping("/api")
public class TestController {
	@Autowired
	DispatchService dispatchService;

	@Resource
	WdTrackService wdTrackService;


	Logger log = LoggerFactory.getLogger(TestController.class);
//
//    @Autowired
//    @RequestMapping("/alert")
//    public String callElevator(@RequestBody JSONObject data, HttpServletRequest request) {
//        log.info("request access"+data.toJSONString());
//        return "success";
//    }

	@RequestMapping("/insert")
	public String insert() {
		dispatchService.testInsert();
		return "success";
	}

	@RequestMapping("/select")
	public String select() {
		dispatchService.testSelect();
		return "success";
	}

	@RequestMapping("/faceSearch")
	public String testFaceLibSearch() {
		dispatchService.testFaceLibSearch();
		return "success";
	}

	@RequestMapping("/execute")
	public String faceInsert() {
		dispatchService.execute();
		return "success";
	}


	@RequestMapping("/points")
	public String getPoints() {
		return JSONObject.toJSONString(wdTrackService.tracePointMap);
	}

	@RequestMapping("/captureTime")
	public String getCaptureTime() {
		return JSONObject.toJSONString(wdTrackService.lastCaptureTimeMap);
	}

	@RequestMapping("/sceneImage")
	public String getSceneImage() {
		return JSONObject.toJSONString(wdTrackService.sceneMap);
	}

	@RequestMapping("/stair")
	public String getStairLocation() {
		return JSONObject.toJSONString(wdTrackService.stairLocation);
	}

	@RequestMapping("/frame")
	public String getFrame() {
		return JSONObject.toJSONString(wdTrackService.frameMap);
	}

	@RequestMapping("/write")
	public String write() {
		wdTrackService.addTrackRecord();
		return "success";
	}

	@RequestMapping("/change")
	public String getPoints(@RequestParam("state") int state) {
		if (state == 1) {
			wdTrackService.WRITE_STATE = true;
		} else {
			wdTrackService.WRITE_STATE = false;
		}
		return "success";
	}
}
